﻿
// PocketServView.cpp: CPocketServView 类的实现
//

#include "pch.h"
#include "framework.h"
// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的
// ATL 项目中进行定义，并允许与该项目共享文档代码。
#ifndef SHARED_HANDLERS
#include "PocketServ.h"
#endif

#include "PocketServDoc.h"
#include "PocketServView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CPocketServView

IMPLEMENT_DYNCREATE(CPocketServView, CView)

BEGIN_MESSAGE_MAP(CPocketServView, CView)
	// 标准打印命令
	ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
	ON_COMMAND(ID_CANCEL_EDIT_SRVR, &CPocketServView::OnCancelEditSrvr)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CView::OnFilePrintPreview)
END_MESSAGE_MAP()

// CPocketServView 构造/析构

CPocketServView::CPocketServView() noexcept
{
	// TODO: 在此处添加构造代码

}

CPocketServView::~CPocketServView()
{
}

BOOL CPocketServView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: 在此处通过修改
	//  CREATESTRUCT cs 来修改窗口类或样式

	return CView::PreCreateWindow(cs);
}

// CPocketServView 绘图

void CPocketServView::OnDraw(CDC* pDC)
{
    CPocketServDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    if (!pDoc)
        return;

    // TODO: 在此处为本机数据添加绘制代码
    CBrush brush;
    brush.CreateSolidBrush(RGB(0, 0, 255));
    CBrush* pBrush = pDC->SelectObject(&brush);
    CFont font;
    font.CreateFont(-500, 0, 0, 0, 400, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS,
        CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, L"Arial");
    CFont* pFont = pDC->SelectObject(&font);
    CRect rectClient;
    GetClientRect(rectClient);
    CSize sizeClient = rectClient.Size();
    pDC->DPtoHIMETRIC(&sizeClient);
    CRect rectEllipse(sizeClient.cx / 2 - 1000, -sizeClient.cy / 2 + 1000,
        sizeClient.cx / 2 + 1000, -sizeClient.cy / 2 - 1000);
    pDC->Ellipse(rectEllipse);

    int nLength = pDoc->m_strText.GetLength();

    pDC->TextOutW(0, 0, pDoc->m_strText, nLength);
    pDC->SelectObject(pFont);
    pDC->SelectObject(pBrush);
}


// CPocketServView 打印

BOOL CPocketServView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// 默认准备
	return DoPreparePrinting(pInfo);
}

void CPocketServView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: 添加额外的打印前进行的初始化过程
}

void CPocketServView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: 添加打印后进行的清理过程
}

// OLE 服务器支持

// 以下命令处理程序提供了标准键盘
//  用户界面以取消就地编辑会话。  此处，
//  服务器(而不是容器)将导致停用
void CPocketServView::OnCancelEditSrvr()
{
	GetDocument()->OnDeactivateUI(FALSE);
}


// CPocketServView 诊断

#ifdef _DEBUG
void CPocketServView::AssertValid() const
{
	CView::AssertValid();
}

void CPocketServView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CPocketServDoc* CPocketServView::GetDocument() const // 非调试版本是内联的
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CPocketServDoc)));
	return (CPocketServDoc*)m_pDocument;
}
#endif //_DEBUG


// CPocketServView 消息处理程序


void CPocketServView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
    pDC->SetMapMode(MM_HIMETRIC);

    CView::OnPrepareDC(pDC, pInfo);
}
